package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.dao.BookDao;
import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.aopalliance.aop.AspectException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {

        //xml解析
       // ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

        //注解解析
        ApplicationContext ctx=new AnnotationConfigApplicationContext(SpringConfig.class);

        UserService userService = (UserService) ctx.getBean("userService");
        userService.save();
//
//        UserDao userDao = (UserDao) ctx.getBean("userDao");
//        userDao.save();
//
//        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
//        bookDao.save();

        AspectException ae = (AspectException) ctx.getBean("aspectException");

        String message = ae.getMessage();
        System.out.println(message);

    }
}
